<?php
  require __DIR__.'/head.html';
  require __DIR__.'/header.html';
  $File_Ming = 'whitelist';
  require __DIR__.'/nav.html';
?>
<style>
    a:link {
        text-decoration: none;
    }

    a:active {
        text-decoration: blink
    }

    a:hover {
        text-decoration: underline;
    }

    a:visited {
        text-decoration: none;
    }

    *,
    :after,
    :before {
        /* -webkit-box-sizing: border-box; */
        -moz-box-sizing: border-box;
        box-sizing: border-box;
    }

    .layui-text ul {
        padding: 0;
    }

    .form-control {
        height: 37px;
    }

    button,
    html input[type=button],
    input[type=reset],
    input[type=submit] {
        -webkit-appearance: button;
        cursor: pointer;
    }
</style>
<!-- 主体 -->
<main class="app-content">
    <div class="app-title">
        <ul class="app-breadcrumb breadcrumb">
            <li class="breadcrumb-item"><i class="fa fa-home fa-lg"></i></li>
            <li class="breadcrumb-item">白名单</li>
        </ul>
    </div>

    <div class="row">
        <div class="col-md-12">
            <div class="tile">
                <div class="bs-component">
                    <div class="alert alert-dismissible alert-success">
                        <button class="close" type="button" data-dismiss="alert">×</button>
                        使用本平台接口必须添加请求服务器IP地址到白名单,多个IP使用英文【;】隔开,若公开接口填写【*】。
                    </div>
                </div>
                <form class="layui-form layui-form-pane" id="user-whitelist">
                    <div class="form-group">
                        <label class="control-label">接口白名单</label>
                        <textarea class="form-control" name="roster" rows="10" style="height: 150px;"
                            placeholder="127.0.0.1 多个请用 ; 隔开"><?php echo $data['w_ip'];?></textarea>
                    </div>

                    <div style="text-align: center;margin: auto;">
                        <button onclick="editip(this)" type="button" class="btn btn-primary btn-block">保存</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <?php  require __DIR__.'/fooer.html'; ?>
    <script type="text/javascript">
        function editip(_this) {
            console.log(_this.title);
            fd = new FormData(document.getElementById('user-whitelist'));
            $.ajax({
                url: '/user/apiip',
                type: "POST",
                timeout: "5000",
                dataType: "json",
                contentType: 'application/x-www-form-urlencoded;charset=utf-8',
                data: fd,
                contentType: false,
                processData: false,
                success: function (data) {
                    if (data.code == "200") {
                        layer.msg(data.msg, { time: 1000 }, function () {
                            location.reload();//刷新父页面
                        });
                    } else {
                        layer.msg(data.msg);
                    }
                },
                error: function (XMLResponse) {
                    layer.msg(XMLResponse.error);
                }
            });
        }
    </script>
    </body>

    </html>